/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using DaveSexton.DocProject;
using DaveSexton.DocProject.Engine;
using VSLangProj80;
using DaveSexton.DocProject.Sandcastle;

namespace DaveSexton.DocProject.DeploymentSandcastle
{
	public class DeploymentSandcastleBuildEngine : SandcastleBuildEngine
	{
		#region Public Properties
		public new DeploymentSandcastleProjectOptions Options
		{
			get
			{
				return (DeploymentSandcastleProjectOptions) base.Options;
			}
		}
		#endregion

		#region Private / Protected
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="DeploymentSandcastleBuildEngine" /> class.
		/// </summary>
		public DeploymentSandcastleBuildEngine(IDocProject project)
			: base(project)
		{
		}
		#endregion

		#region Methods
		public virtual IEnumerable<DeploymentContent> GetContent(DeploymentContentTypes contentTypes, DeploymentContext context)
		{
			return DeploymentContentFactory.CreateContent(contentTypes, context);
		}

		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
		protected override BuildStepCollection CreateSteps()
		{
			BuildStepCollection steps = base.CreateSteps();

			steps.Add(new DeploymentSandcastleBuildStep(this, GetContent));

			return steps;
		}

		protected override void CreateDocSiteFiles(BuildContext context)
		{
			base.CreateDocSiteFiles(context);

			// The DocSite files are created out-of-band so this step must be executed after
			// the normal set of steps have been executed.
			using (DeploymentSandcastleBuildStep step = new DeploymentSandcastleBuildStep(this, GetContent))
			{
				step.DeployDocSiteContentOnly = true;

				base.ExecuteStep(step, context);
			}
		}
		#endregion
	}
}
